import type { BasicTableProps } from '@/components/table/src/props';

export function useLoading(props: ComputedRef<BasicTableProps>) {
  const loadingRef = ref(false);

  watch(
    () => unref(props).loading,
    loading => {
      loadingRef.value = loading;
    },
  );

  const getLoading = computed(() => unref(loadingRef));

  function setLoading(loading: boolean) {
    loadingRef.value = loading;
  }

  return { getLoading, setLoading };
}
